<?php
$url = new Url();
$arr_status = LoadConfig::$status;
?>
<script type="text/javascript">
function ajaxSaveEmbed(){
        var strUrl = "<?=$url->createUrl("embed/ajaxSaveEmbed") ?>";
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                title_embed:$("#title_embed").val(),
                game_ids:$("#game_ids").val(),
                type_display:$("#type_display").val(),
                status:0,
            },
            success: function(msg){
                if(msg == 1){
                    alert('Thêm thành công');  
                    window.location = '<?php echo $url->createUrl("embed/index")?>';
                }else{
                    $("#show_error").html(msg);
                }
            },
            beforeSend:function(){
                $("#button_save").attr("disabled","disabled");
            },
            complete:function(){
                $("#button_save").removeAttr("disabled"); 
            }          
        });
    }
</script>
<div class="main clearfix">
    <div class="title-blue">
        <h3><strong>Thêm mới bộ game</strong></h3>
    </div>
    <div class="box clearfix bottom30">
        <ul class="form4">
            <li class="clearfix">
                <label><strong>Tên bộ mã nhúng</strong>:</label>
                <div class="filltext">
                    <input id="title_embed" type="text" value="" style="width:50%">
                </div>
            </li>


            <li class="clearfix"><label><strong>Thêm game</strong>:</label>
                <div class="filltext">
                    <textarea style="width:50%;height:100px" id="game_ids"></textarea>
                    <p><em>Nhập ID game, mỗi ID cách nhau dấu (,)</em></p>

                </div>
            </li>
            <li class="clearfix"><label><strong>Kiểu mã nhúng</strong>:</label>
                <div class="filltext">
                     <select style="width:203px;" id="type_display">
                        <?php foreach(LoadConfig::$type_display as $key=>$value){?>
                            <option value="<?php echo $key;?>">Kiểu <?php echo $key?></option>
                            <?php }?>
                    </select>
                </div>
            </li>
             <!--<li class="clearfix"><label><strong>Trạng thái</strong>:</label>
                <div class="filltext">
                    <select style="width:203px;" id="status">
                        <?php foreach($arr_status as $key=>$value){?>
                            <option value="<?php echo $key;?>"><?php echo $value?></option>
                            <?php }?>
                    </select>
                </div>
            </li>-->

            <li class="clearfix"><label>&nbsp;</label>
                <div class="filltext">
                    <input id="button_save" onclick="ajaxSaveEmbed();" type="button" value=" Thêm mới " class="btn-bigblue"> 
                    &nbsp;
                    <input onclick="history.go(-1)" type="button" value=" Quay lại " class="btn-bigblue"> 
                </div>
            </li>
            <li class="clearfix"><label>&nbsp;</label>
                <div class="filltext" style="color: red;" id="show_error"></div>
            </li>
        </ul>

    </div>
</div>